﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BLL;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           
        }
        
    }


    protected void TxtPassword_TextChanged(object sender, EventArgs e)
    {

    }
    protected void ButLogin_Click(object sender, EventArgs e)
    {
         UserInfoManager user1 = new UserInfoManager();
        string name = TxtName.Text.Trim().ToString ();
        if (user1.isExists(name))
        {
            string pwd = TxtPassword.Text.Trim().ToString();
            if (LoginManager.Login(name, pwd))
            {
                Session["admin"] = name;
                Response.Redirect("../Web/UserInformation.aspx");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('密码错误!');</script>");
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('用户名不存在!');</script>");
        }
        
    }
    protected void ButRegister_Click(object sender, EventArgs e)
    {
        Response.Redirect("Register.aspx");
    }
}
